#!/usr/bin/python

# This is a server file

import socket			# Import socket module

s = socket.socket()		# Create socket 
host = socket.gethostname()	
port = 12345
s.bind((host,port))

s.listen(10)			# Wait for connection
print "Now start listening..."
while True:
	c, addr = s.accept()	# Establish connection with client;
	print 'Got connection form', addr
	c.send('Thank you for connecting')
	recv = c.recv(1024)
	while recv != 'Disconnect':
		print "Client: ", recv
		str = raw_input('You: ')
		c.send(str)
		recv = c.recv(1024)
	c.send("Disconnect")
	print "Disconnected", addr
	c.close()

